package com.audaque.jadmin.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.audaque.jadmin.system.dao.mybatis.ResourceMapper;
import com.audaque.jadmin.system.dao.mybatis.RoleMapper;
import com.audaque.jadmin.system.model.Resource;
import com.audaque.jadmin.system.model.Role;
import com.audaque.jadmin.system.service.ResourceService;

/**
 * @Description :
 * @FileName: ResourceServiceImpl.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年10月26日 下午6:38:19
 * @Version:V1.00
 */
@Service("resourceService")
public class ResourceServiceImpl implements ResourceService {

	@Autowired
	private ResourceMapper resourceMapper;

	@Autowired
	private RoleMapper roleMapper;

	@Override
	public List<Resource> queryByUserId(int userId) {
		List<Role> roles = roleMapper.findByUserId(userId);

		List<Resource> resources = resourceMapper.queryByRoleIds(roles);

		for (Resource resource : resources) {
			System.out.println(resource);
		}

		return resourceMapper.queryByUserId(userId);
	}

}
